package com.bejoy.coolatin;

import org.json.JSONException;
import org.json.JSONObject;

import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.bejoy.coolatin.util.ObtainInterfaceUtil;
import com.bejoy.coolatin.util.StaticProperty;
import com.bejoy.coolatin.volley.InterfaceViaVolleys;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 个人中心页面
 * @author Tien.
 *
 */
public class PersonalCenterActivity extends Activity implements OnClickListener{
	
	SharedPreferences share;
	ObtainInterfaceUtil obtainInterfaceUtil ;
	private ImageView back,headImage;
	private TextView name;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_personlcenter);
		initItem();
	}

	private void initItem(){
		share = getSharedPreferences(StaticProperty.SAVEINFO, Activity.MODE_PRIVATE);
		obtainInterfaceUtil = new ObtainInterfaceUtil();
		
		back = (ImageView) findViewById(R.id.back_personal_center);
		headImage = (ImageView) findViewById(R.id.headImage_personal_center);
		name = (TextView) findViewById(R.id.name_personal_center);
		
		name.setText(share.getString(StaticProperty.NICKNAME, "游客"));
		
		headImage.setTag(share.getString(StaticProperty.USERPHOTO, ""));
		obtainInterfaceUtil.loadCircleBitmap(share.getString(StaticProperty.USERPHOTO, ""), headImage, true);
		back.setOnClickListener(this);
	}
	
//	private void loadData(){
//		new InterfaceViaVolleys(null, StaticProperty.IPADDRESS + "user/customDetail?tokenId=" + tokenId, null,
//				new Response.Listener<String>() {
//
//					@Override
//					public void onResponse(String response) {
//						try {
//							JSONObject jsonObject = new JSONObject(response);
//							if (jsonObject.getString("result") != null && !"".equals(jsonObject.getString("result"))
//									&& jsonObject.getInt("status") == 1) {
//								
//							}
//						} catch (JSONException e) {
//							e.printStackTrace();
//						}
//					}
//				}, new Response.ErrorListener() {
//
//					@Override
//					public void onErrorResponse(VolleyError error) {
//						
//					}
//				}).stringRequest();
//	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.back_personal_center:
			finish();
			break;
		
		}
	}
}
